﻿using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.ApplicationInsights;

namespace Shared.Service.Logging.ApplicationInsights
{
    public static class ApplicationInsightsLoggerExtension
    {
        public static void AddApplicationInsightsLogger(this ILoggingBuilder builder, HostBuilderContext builderContext)
        {
            var appInsightKey = builderContext.Configuration["ApplicationInsights:InstrumentationKey"];
            builder.AddApplicationInsights(appInsightKey);
            builder.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Information);
        }
    }
}
